import { sendRequest } from '@/http';

const baseUrl = '/admin/device/alarmorder';

/**
 * 查询报警工单
 * @param
 * @returns
 */
export const queryDeviceAlarmOrderList = (params: {
  page: number;
  pageSize: number;
  deviceName?: string;
  status?: string;
}) => {
  return sendRequest({
    url: `${baseUrl}/queryDeviceAlarmOrderList`,
    method: 'get',
    params: params as any,
  });
};

/**
 * 查询工单详情
 * @param orderId 工单ID
 * @returns
 */
export const queryDeviceAlarmOrderDetail = (orderId: string) => {
  return sendRequest({
    url: `${baseUrl}/queryDeviceAlarmOrderDetail`,
    method: 'get',
    params: { orderId },
  });
};

/**
 * 派发设备报警工单
 * @param data
 * @returns
 */
export const assignDeviceAlarmOrder = (data: {
  /** 工单ID */ 
  orderId?: string;
  /** 接单站点ID */
  assignStationId?: string;
  /** 接单人员ID */
  assignStaffId?: string;
  /** 派发备注 */
  assignRemark?: string;
}) => {
  return sendRequest({
    url: `${baseUrl}/assignDeviceAlarmOrder`,
    method: 'post',
    data: data as any,
  });
};

/**
 * 关闭设备报警工单
 * @param data
 * @returns
 */
export const closeDeviceAlarmOrder = (data: {
  /** 工单ID */ 
  orderId?: string;
  /** 处理方式 */
  handleMethod?: string;
  /** 处理结果 */
  handleResult?: string;
  /** 备注 */
  remark?: string;
  resources?: any[];
}) => {
  return sendRequest({
    url: `${baseUrl}/closeDeviceAlarmOrder`,
    method: 'post',
    data: data as any,
  });
};

/**
 * 生成线下处理图片上传Token
 * @param data
 * @returns
 */
export const genOfflineOrderImageUploadToken = (data: {
  /** 工单ID */ 
  orderId?: string;
  /** 本地图片文件名称 */
  fileName?: string;
}) => {
  return sendRequest({
    url: `${baseUrl}/genOfflineOrderImageUploadToken`,
    method: 'post',
    data: data as any,
  });
};
